object ForGuardDemo extends App {
  //定义班级英语成绩
  val englishScore: Array[Int] = Array(75, 58, 90, 65, 52, 88, 72, 45, 68, 70, 59, 82)

  //初始化变量
  var passCount = 0
  val totalStudents = englishScore.length
  val passScores = collection.mutable.ListBuffer[Int]()

  //使用for循环守卫筛选及格成绩
  for (score <- englishScore if score >=60) {
    passCount += 1
    passScores += score
    println(s"及格成绩：$score")
  }

  //计算及格率
  val passRate = (passCount.toDouble / totalStudents) * 100

  //输出结果
  println(s"\n及格成绩列表：$passScores")
  println(s"及格人数：$passCount/$totalStudents")
  println(f"及格率：$passRate%.1f%%")
}
//第九周（动手练习2：筛选及格成绩并统计数量）